<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[#include "../inc/common/base.html"]
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta name="Generator" content="ECSHOP v2.7.2" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="Keywords" content="" />
		<meta name="Description" content="" />
		<title>用户订单</title>
		<link href="${path}/css/style.css" rel="stylesheet" type="text/css" />
	</head>
	<script type="text/javascript">
		var postInfo = [];
		
		function checkOrderForm(obj){
			payMode = $("input:checked[name=payMode]").val();
			// 检查输入
			var msg = "";
			
			if (Utils.isEmpty(payMode)) {
				msg += '请选择支付方式！\n';
			}
			
			if (!Utils.isEmpty(msg)) {
				alert(msg);
				return false;
			}
			
			var payTotal = parseFloat($("#payTotal").html());
			if(payTotal <= 0){
				alert("购物车为空，无法提交订单！");
				return false;
			}
		}
	</script>
	<body>
		[#include "../inc/common/head.html"]
		<div class="block box">
			<div id="ur_here">
				当前位置:
				<a href="${var_contextpath}/index.xhtml">首页</a><code>&gt;</code>提交订单
			</div>
		</div>
		<div class="blank"></div>
		<div class="block">
			<form action="${var_contextpath}/order/submit.xhtml" method="post"
				name="theForm" id="theForm" onsubmit="return checkOrderForm(this)">
				<input type="hidden" id="btn_postage" name="btn_postage" value="0" />
				<input type="hidden" id="btn_coupon" name="btn_coupon" value="0" />
				<input type="hidden" id="btn_coupon_id" name="btn_coupon_id"/>
				
				[#include "../inc/order/detailGoodsList.html"]
				[#--读取购物车信息数据的自定义标签，参数：par_memberid(用户ID)--] 
				[@ecs_cartlist par_memberid = var_memberid] 
					[@ecs_cartlistinfo datalist = var_cartinfo/]
				[/@ecs_cartlist]
				<div class="blank"></div>
				[#include "../inc/order/receiverInfo.html"]
				<div class="blank"></div>
				<div class="flowBox">
					<h6>
						<span>配送方式</span>
					</h6>
					<table width="99%" align="center" border="0" cellpadding="5"
						cellspacing="1" bgcolor="#dddddd" id="shippingTable">
						<tr>
							<th bgcolor="#ffffff" width="5%">
								&nbsp;
							</th>
							<th bgcolor="#ffffff" width="25%">
								名称
							</th>
							<th bgcolor="#ffffff">
								订购描述
							</th>
						</tr>
						[@ecs_postagelist]
							[#assign i = 0]
							[#list var_postageinfo as data]
								<tr>
									<td bgcolor="#ffffff" valign="top">
										<input id="deliveryMode-${i}" type="radio" value="${i}"
											onclick="initPostAge(${i})" />
									</td>
									<td bgcolor="#ffffff" valign="top">
										<strong>${data.bdmName}</strong>
									</td>
									<td bgcolor="#ffffff" valign="top">
										${data.bdmRule}
									</td>
								</tr>
								<script type="text/javascript">
									var obj = {
										bdmId : "${data.bdmId}",
										bdmName: "${data.bdmName}",
										bdmRule: "${data.bdmRule}",
										bdmScript : "${data.bdmScript}",
										bdmInvoke : "${data.bdmInvoke}"
									};
									postInfo.push(obj);
								</script>
								[#assign i = i+1]
							[/#list]	
						[/@ecs_postagelist]
					</table>
				</div>
				<div class="blank"></div>
				<div class="flowBox">
					<h6>
						<span>支付方式</span>
					</h6>
					<table width="99%" align="center" border="0" cellpadding="5"
						cellspacing="1" bgcolor="#dddddd" id="paymentTable">
						[@ecs_paymodelist par_paymodetype = 1]
						[#if var_paymodeinfo??]
						<tr>
							<th bgcolor="#ffffff" align="left">
								在线支付
							</th>
						</tr>
						<tr>
							<td bgcolor="#ffffff">
								<ul>
								[#list var_paymodeinfo as data]
									<li style="list-style-type:none;float:left;">
										<input name="payMode" type="radio" value="${data.bmpId}" />
										<img src="${path}/images${data.bmpIconurl}"/>${data.bmpName}
									</li>
								[/#list]	
								</ul>
							</td>
						</tr>
						[/#if]
						[/@ecs_paymodelist]
						[@ecs_paymodelist par_paymodetype = 2]
						[#if var_paymodeinfo??]
						<tr>
							<th bgcolor="#ffffff" align="left">
								第三方支付
							</th>
						</tr>
						<tr>
							<td bgcolor="#ffffff">
								<ul>
								[#list var_paymodeinfo as data]
									<li style="list-style-type:none;float:left;">
										<input name="payMode" type="radio" value="${data.bmpId}" />
										<img src="${path}/images${data.bmpIconurl}"/>${data.bmpName}
									</li>
								[/#list]	
								</ul>
							</td>
						</tr>
						[/#if]
						[/@ecs_paymodelist]
						[@ecs_paymodelist par_paymodetype = 0]
							[#if var_paymodeinfo??]
								<tr>
									<th bgcolor="#ffffff" align="left">
										货到付款
									</th>
								</tr>
								<tr>
									<td bgcolor="#ffffff">
										<ul>
										[#list var_paymodeinfo as data]
											<li style="list-style-type:none;float:left;">
												[#if var_iscashondelivery??]
													[#if var_iscashondelivery]
														<input name="payMode" type="radio" value="${data.bmpId}" />
														<img src="${path}/images${data.bmpIconurl}"/>${data.bmpName}(${data.bmpDescript})
													[#else]
														<input name="payMode" type="radio" disabled/>
														<img src="${path}/images${data.bmpIconurl}"/>${data.bmpName}(您的收货地区不支持货到付款。)
													[/#if]
												[/#if]
											</li>
										[/#list]	
										</ul>
									</td>
								</tr>
							[/#if]
						[/@ecs_paymodelist]
					</table>
				</div>				
				<div class="blank" id="couponDiv1"></div>
				<div class="flowBox" id="couponDiv2">
					<h6>
						<span>我的购物券</span>
					</h6>
					<table id="couponTb" width="99%" align="center" border="0" cellpadding="5"
						cellspacing="1" bgcolor="#dddddd">
						<tr>
							<th bgcolor="#ffffff">购物券名</th>
							<th bgcolor="#ffffff">面值金额</th>
							<th bgcolor="#ffffff">拥有数量</th>
							<th bgcolor="#ffffff">选择</th>
						</tr>
					</table>
				</div>
				<div class="blank"></div>
				<div class="flowBox">
					<h6>
						<span>其它信息</span>
					</h6>
					<table width="99%" align="center" border="0" cellpadding="5"
						cellspacing="1" bgcolor="#dddddd">
						<tr>
							<td valign="center" bgcolor="#ffffff">
								<strong>备注:</strong>
							</td>
							<td bgcolor="#ffffff">
								<textarea name="remarks" cols="100" rows="2" id="remarks"
									style="border: 1px solid #ccc;"></textarea>
							</td>
						</tr>
					</table>
				</div>
				<div class="blank"></div>
				<div class="flowBox">
					<h6>
						<span>费用总计</span>
					</h6>
					<div id="ECS_ORDERTOTAL">
						<table width="99%" align="center" border="0" cellpadding="5"
							cellspacing="1" bgcolor="#dddddd">
							<tr>
								<td align="right" bgcolor="#ffffff">
									该订单完成后，您将获得
									<font class="f4_b"><label id="integrate">0</label></font> 积分
								</td>
							</tr>
							<tr>
								<td align="right" bgcolor="#ffffff">
									 商品总额:
									<font class="f4_b">￥<label id="goodsTotal">0</label>元</font>
								</td>
							</tr>
							<tr id="postageTr" style="display:none;">
								<td align="right" bgcolor="#ffffff">
									 + 配送费用:
									<font class="f4_b">￥<label id="postage">0</label>元</font>
								</td>
							</tr>
							<tr id="couponTr" style="display:none;">
								<td align="right" bgcolor="#ffffff">
									 - 购物券金额:
									<font class="f4_b">￥<label id="couponPrice">0</label>元</font>
								</td>
							</tr>
							<tr>
								<td align="right" bgcolor="#ffffff">
									应付总金额:
									<font class="f4_b">￥<label id="payTotal">0</label>元</font>
								</td>
							</tr>
						</table>
					</div>
					<div align="center" style="margin: 8px auto;">
						<input type="image" src="${path}/images/bnt_subOrder.gif" />
					</div>
				</div>
			</form>
		</div>
		<div class="blank5"></div>
		[#include "../inc/common/help.html"]
		[#include "../inc/common/bottomNav.html"]
		[#include "../inc/common/footer.html"]
	</body>
</html>
<script type="text/javascript">
	function initPostAge(i){
		var result = 0;
		var productTotal = document.getElementById("goodsTotal").innerHTML;
		var invoke = postInfo[i].bdmInvoke;
		var script = postInfo[i].bdmScript;
		eval(script);
  		result = eval(invoke);
  		
  		if(result > 0){
  			$("#postageTr").show();
			$("#btn_postage").val(result);
			$("#postage").html(result);
		}
		
		$("#payTotal").html(parseFloat(productTotal) + result);
	}
	
	$(function(){
		$("#deliveryMode-0").attr("checked",true);
		initPostAge(0);
	});
</script>
